<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
</head>
<body>

<p></p>
<form>
    用户名：<input type="text" name="username" id="username"> <br>
    密码<input type="password" name="password" id="password"> <br>
    <input type="button" value="注册"  onclick="register()">
</form>

</body>
</html>

<script>
    function register() {
        $.ajax({
            type:'POST',
            url:'/demo/register',
            data:{
                "username":$("#username").val(),
                "password":$("#password").val()
            },
            success:function (result) {
                console.log(result);
                if (result.code===200){
                    //window.location.href="/demo/login.html"
                }
                else {
                    $("p").text(result.message);
                }

            }
        })
    }

</script>